#!/usr/bin/python3

import rospy
import tf2_ros
import math
import tf


rospy.init_node('get_pos', anonymous=True)
tf_buffer = tf2_ros.Buffer()
tf2_ros.TransformListener(tf_buffer)
rate = rospy.Rate(100)
while not rospy.is_shutdown():
    try:
        #transform = self.tf_buffer.lookup_transform('map', 'laser_frame', rospy.Time(0))
        transform = tf_buffer.lookup_transform('odom', 'laser', rospy.Time(0))
        # 提取位姿数据
        translation = transform.transform.translation
        rotation = transform.transform.rotation
        rospy.loginfo("X:%.3f, Y:%.3f", translation.x * 100, translation.y * 100)
    except:
        pass

    rate.sleep()

